package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.Hotel;
import cn.wolfcode.trip.base.query.HotelQueryObject;
import cn.wolfcode.trip.base.service.IHotelService;
import cn.wolfcode.trip.base.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Auther: Killua
 * @Date: 2018/10/11 22:25
 * @Description:
 */
@RequestMapping("hotels")
@RestController
public class HotelController {
    @Autowired
    private IHotelService hotelService;

    @GetMapping
    public Object queryHotel(HotelQueryObject qo) {
        JsonResult jsonResult = new JsonResult();

        List<Hotel> hotelList = hotelService.queryByAddressNameHotel(qo);
        System.out.println(hotelList);
        if (hotelList.size()==0) {
            jsonResult.mark("请输入正确地址");
            return jsonResult;
        } else {
            jsonResult.setResult(hotelList);
            return jsonResult;
        }

    }


}
